#pragma once
#include "INoiseGenerator.h"
#include "Point.h"
#include <algorithm>
#include <math.h>
class WorleyNoise :
	public INoiseGenerator
{
private:
	float DistanceArray[3];

	float CombinerFunction1(float ar[]);
	float CombinerFunction2(float ar[]);
	float CombinerFunction3(float ar[]);

	float EuclidianDistanceFunc(Point p1, Point p2);
	float ManhattanDistanceFunc(Point p1, Point p2);
	float ChebyshevDistanceFunc(Point p1, Point p2);

	long probLookup(long value);
	void insert(float  arr[], float value);
	long lcgRandom(long lastValue);
	long hash(long i, long j, long k);
	float noise(Point input);
public:
	int DistanceFunction = 0;
	int CombineDistanceFunction = 0;
	int Seed = 3221;

	int OFFSET_BASIS = 2166136261;
	int FNV_PRIME = 16777619;

	float Get1D(float x) override;
	float Get2D(float x, float y) override;

	WorleyNoise();
	~WorleyNoise();
};

